home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************
- * This is loaded in the sidebar xul document
- *****************************************************/
-
- Components.utils.import("resource://yoono/yoonoService.js");
- Components.utils.import("resource://yoono/yoonoYEXTIF.js");
- Components.utils.import("resource://yoono/yoonoSidebarService.js");
- Components.utils.import("resource://yoono/yoonoPrefs.js");
- Components.utils.import("resource://yoono/yoonoLog.js");
-
- var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIWebNavigation)
- .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
- .rootTreeItem
- .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIDOMWindow)
-
- var yoonoGlob = mainWindow.yoonoGlob;
- var YoonoSidebar = mainWindow.YoonoSidebar;
- var sidebar = yoonoGlob.sidebar;
-
-
-
- // this is called only from code in the sidebar xul document
- // It is called each time the sidebar is opened
- // The YoonoSidebar Class is defined in \chrome\content\yoono\sidebar.js and enriched here
- // WARNING : The document actually loaded can be the wizard.html or the sidebar.html file
- YoonoSidebar.prototype.init = function() {
- //dump(new Date().getTime()+" :: chrome.YoonoSidebar.init\n");
-
- YOONO_LOG.debug("YoonoSidebar.init: Entering");
- try {
- this.visible = true;
- this.domElt = document.getElementById('sidebar');
- this.iframe = document.getElementById('yoonosb-iframe');
- this.externalInterfaces.setSbIframe(this.iframe);
- this.win = this.iframe.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);
- this.doc = this.iframe.docShell.document;
- this.sidebarMethods = this.win.YINTIF;
- for(var method in this.methods) {
- this.win.YEXTIF.methods[method] = this.methods[method];
- }
-
- // In case we are opening the wizard, the page to open can be a parameter in query
- var query = document.location.search.substr(1).split('=');
- var stage = '';
- if(query && query[1]) {
- stage = query[1];
- }
-
- // This will load global services and then call yoonoSidebarInit function with stage as argument
- YOONO_CMPT.getYServices().core.initSubDocument(this.win,"yoonoSidebarInit",[YOONO_YEXTIF.getWindowId(mainWindow), stage]);
- var _self=this;
- window.setTimeout(function () {
- //dump("Display sidebar!!!\n");
- _self.browser.parentNode.removeAttribute("style"); // Remove the max-width set in content/sidebar.js
- var memorizedWidth = _self.browser.parentNode.getAttribute('width'); // this.browser is initialized in sidebar.js
- // TODO : sidebar default size was originaly initialized by the sidebar.js in sidebar.html (not in extension side)
- // TODO : but now with TOS in sidebar, we first need to validate TOS before loading sidebar.html, causing on new firefox profile a 0 width sidebar
- // TODO : (this does not affect upgradded or reinstalled yoono because the size is saved as persistant xul attribute)
- // TODO : this is a workaround to prevent buggy and undef values :
- if(!memorizedWidth || memorizedWidth<0){
- memorizedWidth = 267;
- //dump("warning : memorizedWidth not set. Set to default "+memorizedWidth);
- };
- sidebar.setLarge(memorizedWidth);
- },0);
-
- } catch(e) {
- YOONO_LOG.exception(e);
- }
- }
-
-
- // Called when unload event fires
- YoonoSidebar.prototype.uninit = function() {
- try {
- // Is is called twice because unload events trigger in both xul and html documents
- if(!this.win) return;
- YOONO_LOG.debug("YoonoSidebar.uninit: Quiting");
- this.domElt = null;
- this.iframe = null;
- this.doc = null;
- this.sidebarMethods = null;
- this.visible = false;
- // Call goodbye method of HTML code
- this.win.yoonoSidebarQuit();
- this.win = null;
- } catch(e) {
- YOONO_LOG.exception(e);
- }
- }
-
- // called on the onload of the sidebar.xul document, that fires after the html document
- // was loaded in the sidebar iframe
- function init() {
- try {
- // calling the init method of the sidebar object
- sidebar.init();
- // when mouse is exiting from the sidebar, it might have to be reduced back to thin mode
- // A listener will be in charge of that.
- if(sidebar.win && ('ynSidebar' in sidebar.win)) {
- window.addEventListener('mouseout', function(evt){
- if(('iframe' == evt.target.nodeName) && ('yoonosb-iframe' == evt.target.id) && (sidebar.win.ynSidebar)) {
- sidebar.win.ynSidebar.mouseOut();
- }
- }, true);
- }
- } catch(e) {
- YOONO_LOG.exception(e);
- }
- }
-
- function uninit() {
- sidebar.uninit();
- }
-
-
- // DIFFERENT TESTS, unused so far
- function dropOnMemoTarget(evt) {
- // recupérer la session de Dnd
- var dragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService(Components.interfaces.nsIDragService);
- var dragSession = dragService.getCurrentSession();
- // Préparer un objet pour récupérer les données draguées
- var transferObject = Components.classes["@mozilla.org/widget/transferable;1"].createInstance();
- transferObject = transferObject.QueryInterface(Components.interfaces.nsITransferable);
- // Préciser le format qu'on souhaite lire
- var type = "text/html";
- if(dragSession.isDataFlavorSupported('video')) {
- type = "video";
- }
- transferObject.addDataFlavor(type);
- dragSession.getData(transferObject, 0);
-
- var dataObj = new Object();
- var dropSizeObj = new Object();
- transferObject.getTransferData(type, dataObj, dropSizeObj);
- dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
- //alert('Drop de type ' + type + ' sur ' + evt.target.innerHTML + " : \n" + dataObj);
- yoonoGlob.createMemo();
- }
-
- // UNUSED
- function dragging(evt) {
- var dragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService(Components.interfaces.nsIDragService);
- // Préparer un objet pour récupérer les données draguées
- var transferObject = Components.classes["@mozilla.org/widget/transferable;1"].createInstance();
- transferObject = transferObject.QueryInterface(Components.interfaces.nsITransferable);
- // Préciser le format qu'on souhaite envoyer
- transferObject.addDataFlavor("video");
- //transferObject.addDataFlavor("text/html");
- var bmstring = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
- var texte = evt.target.embedText;
- bmstring.data = texte;
- transferObject.setTransferData('video', bmstring, texte.length*2);
- //transferObject.setTransferData('text/html', bmstring, texte.length*2);
- var transArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
- transArray.AppendElement(transferObject.QueryInterface(Components.interfaces.nsISupports));
- dragService.invokeDragSession(evt.target, transArray, null, dragService.DRAGDROP_ACTION_MOVE);
- }
-
-